import urllib
import json


def Talk(msg):
    url = "http://openapi.tuling123.com/openapi/api/v2"
    data = {
        "reqType": 0,
        "perception": {
            "inputText": {
                "text": msg
            }
        },
        "userInfo": {
            "apiKey": "3b250ce595106c48995ee55528c3f18d",
            "userId": "DwGoing"
        }
    }
    headers = {
        "Content-Type": "application/json"
    }
    data = json.dumps(data).encode(encoding="utf-8")
    request = urllib.request.Request(url, data=data, headers=headers, method="POST")
    response = urllib.request.urlopen(request)
    dataBt = response.read()
    dataStr = dataBt.decode("utf-8")
    return dataStr
